//LCR 179.查找总价格为目标的两个商品
class Solution2 {
    //时间复杂度O(N)
    public int[] twoSum(int[] price, int target) {
        int left = 0;
        int right = price.length-1;    
        while(left < right){
           int sum = price[left] + price[right]; 
           if(sum > target){
            right--;
           }else if(sum < target){
            left++;
           }else{
            return new int[] {price[left],price[right]};
           }
        }
        //一般执行不到这条语句
        return new int[]{0};
    }
}